home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / groff108.lha / groff-1.08 / troff / div.h < prev    next >
C/C++ Source or Header  |  1993-04-02  |  5KB  |  147 lines

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
  3.      Written by James Clark (jjc@jclark.com)
  4.  
  5. This file is part of groff.
  6.  
  7. groff is free software; you can redistribute it and/or modify it under
  8. the terms of the GNU General Public License as published by the Free
  9. Software Foundation; either version 2, or (at your option) any later
  10. version.
  11.  
  12. groff is distributed in the hope that it will be useful, but WITHOUT ANY
  13. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License along
  18. with groff; see the file COPYING.  If not, write to the Free Software
  19. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  20.  
  21. class diversion {
  22.   friend void do_divert(int append);
  23.   friend void end_diversions();
  24.   diversion *prev;
  25. protected:
  26.   symbol nm;
  27.   vunits vertical_position;
  28.   vunits high_water_mark;
  29. public:
  30.   vunits marked_place;
  31.   diversion(symbol s = NULL_SYMBOL);
  32.   virtual ~diversion();
  33.   virtual void output(node *nd, int retain_size, vunits vs, int ls, hunits width) = 0;
  34.   virtual void transparent_output(unsigned char) = 0;
  35.   virtual void transparent_output(node *) = 0;
  36.   virtual void space(vunits distance, int forced = 0) = 0;
  37. #ifdef COLUMN
  38.   virtual void vjustify(symbol) = 0;
  39. #endif /* COLUMN */
  40.   vunits get_vertical_position() { return vertical_position; }
  41.   vunits get_high_water_mark() { return high_water_mark; }
  42.   virtual vunits distance_to_next_trap() = 0;
  43.   void need(vunits);
  44.   const char *get_diversion_name() { return nm.contents(); }
  45.   virtual void set_diversion_trap(symbol, vunits) = 0;
  46.   virtual void clear_diversion_trap() = 0;
  47.   virtual void copy_file(const char *filename) = 0;
  48. };
  49.  
  50. class macro;
  51.  
  52. class macro_diversion : public diversion {
  53.   macro *mac;
  54.   hunits max_width;
  55.   symbol diversion_trap;
  56.   vunits diversion_trap_pos;
  57. public:
  58.   macro_diversion(symbol, int);
  59.   ~macro_diversion();
  60.   void output(node *nd, int retain_size, vunits vs, int ls, hunits width);
  61.   void transparent_output(unsigned char);
  62.   void transparent_output(node *);
  63.   void space(vunits distance, int forced = 0);
  64. #ifdef COLUMN
  65.   void vjustify(symbol);
  66. #endif /* COLUMN */
  67.   vunits distance_to_next_trap();
  68.   void set_diversion_trap(symbol, vunits);
  69.   void clear_diversion_trap();
  70.   void copy_file(const char *filename);
  71. };
  72.  
  73. struct trap {
  74.   trap *next;
  75.   vunits position;
  76.   symbol nm;
  77.   trap(symbol, vunits, trap *);
  78. };
  79.  
  80. struct output_file;
  81.  
  82. class top_level_diversion : public diversion {
  83.   int page_number;
  84.   int page_count;
  85.   int last_page_count;
  86.   vunits page_length;
  87.   hunits prev_page_offset;
  88.   hunits page_offset;
  89.   trap *page_trap_list;
  90.   trap *find_next_trap(vunits *);
  91.   int have_next_page_number;
  92.   int next_page_number;
  93.   int ejecting_page;        // Is the current page being ejected?
  94. public:
  95.   int before_first_page;
  96.   int no_space_mode;
  97.   top_level_diversion();
  98.   void output(node *nd, int retain_size, vunits vs, int ls, hunits width);
  99.   void transparent_output(unsigned char);
  100.   void transparent_output(node *);
  101.   void space(vunits distance, int forced = 0);
  102. #ifdef COLUMN
  103.   void vjustify(symbol);
  104. #endif /* COLUMN */
  105.   hunits get_page_offset() { return page_offset; }
  106.   vunits get_page_length() { return page_length; }
  107.   vunits distance_to_next_trap();
  108.   void add_trap(symbol nm, vunits pos);
  109.   void change_trap(symbol nm, vunits pos);
  110.   void remove_trap(symbol);
  111.   void remove_trap_at(vunits pos);
  112.   void print_traps();
  113.   int get_page_count() { return page_count; }
  114.   int get_page_number() { return page_number; }
  115.   int get_next_page_number();
  116.   void set_page_number(int n) { page_number = n; }
  117.   int begin_page();
  118.   void set_next_page_number(int);
  119.   void set_page_length(vunits);
  120.   void copy_file(const char *filename);
  121.   int get_ejecting() { return ejecting_page; }
  122.   void set_ejecting() { ejecting_page = 1; }
  123.   friend void page_offset();
  124.   void set_diversion_trap(symbol, vunits);
  125.   void clear_diversion_trap();
  126.   void set_last_page() { last_page_count = page_count; }
  127. };
  128.  
  129. extern top_level_diversion *topdiv;
  130. extern diversion *curdiv;
  131.  
  132. extern int exit_started;
  133. extern int done_end_macro;
  134. extern int seen_last_page_ejector;
  135.  
  136. void spring_trap(symbol);    // implemented by input.c
  137. extern int trap_sprung_flag;
  138. void postpone_traps();
  139. int unpostpone_traps();
  140.  
  141. void push_page_ejector();
  142. void continue_page_eject();
  143. void handle_first_page_transition();
  144. void blank_line();
  145.  
  146. extern void cleanup_and_exit(int);
  147.